package com.xqboss.apps.dto.order;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xqboss.apps.dto.PageDto;
import com.xqboss.apps.enums.market.MarketTypeEnum;
import com.xqboss.apps.enums.nft.NftTypeEnum;
import com.xqboss.apps.enums.order.OutOrderStatusEnum;
import com.xqboss.apps.enums.order.OrderStatusEnum;
import com.xqboss.apps.enums.order.OrderTypeEnum;
import com.xqboss.apps.enums.user.PayTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *     获取订单统计信息参数
 * </p>
 * @author Trent
 * @date 2023/8/24
 */
@Data
@ApiModel
public class WebOrderListDto extends PageDto {

    @ApiModelProperty(value = "订单类型",required = true)
    private OrderTypeEnum orderType;

    @ApiModelProperty(value = "市场类型", required = true)
    private MarketTypeEnum marketType;

    @ApiModelProperty("开始时间")
    private LocalDateTime createTimeStart;

    @ApiModelProperty("结束时间")
    private LocalDateTime createTimeEnd;

    @ApiModelProperty("商品分类")
    private Long categoryId;

    @ApiModelProperty("商品ID")
    private Long spuId;

    @ApiModelProperty("买家ID（APP不用传）")
    private Long buyerId;

    @ApiModelProperty("订单状态分类筛选")
    private OutOrderStatusEnum orderStatus;

    @ApiModelProperty("搜索")
    private String search;

    @ApiModelProperty("支付方式")
    private PayTypeEnum payType;


    /**
     * 内部订单状态
     */
    @ApiModelProperty(hidden = true)
    @JsonIgnore
    @Setter(AccessLevel.NONE)
    @Getter(AccessLevel.NONE)
    private List<OrderStatusEnum> orderStatusList;

    public List<OrderStatusEnum> getOrderStatusList(){
        if(Objects.nonNull(orderStatus)){
            return OutOrderStatusEnum.toOrderStatus(orderStatus);
        }
        return null;
    }

    public LocalDateTime getCreateTimeEnd() {
        if(Objects.nonNull(createTimeEnd)){
            return createTimeEnd.with(LocalTime.MAX);
        }
        return createTimeEnd;
    }
}
